package com.design.patterns;

interface Sender{
    void sender();
}

class MailSender implements Sender{
    public void sender(){
        System.out.println("this is mail sender...");
    }
}

class SmsSend implements  Sender{
    public void sender(){
        System.out.println("this is sms sender...");
    }
}

//普通工程模式-根据传入值来创建实例
public class FactoryPattern {

    public static Sender produce(String str){
        if("mail".equals(str)){
            return new MailSender();
        }else if("sms".equals(str)){
            return new SmsSend();
        }else{
            System.out.println("输入错误。。。。");
            return null;
        }
    }

    public static void main(String[] args) {
        Sender s = FactoryPattern.produce("mail");
        s.sender();

        Sender s1 = FactoryPattern.produce("sms");
        s1.sender();
    }
}
